import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { environmentProd } from '../../../../environments/environment-prod';
import { UnifyResponse } from '../../../../common/response';
import { Observable } from 'rxjs';


const baseApiUrl = environmentProd.baseApiUrl


@Injectable({
  providedIn: 'root'
})
export class DeptService {

  private readonly http = inject(HttpClient)

  constructor() { }
  getDepts() : Observable<UnifyResponse<any>> {
    return this.http.get<UnifyResponse<any>>(`${baseApiUrl}/system/dept/list`)
  }

  getDeptsExcludeNode(id: number) {
    return this.http.get(`${baseApiUrl}/system/dept/list/exclude/${id}`)
  }

  deptDetail(id: number) {
    return this.http.get(`${baseApiUrl}/system/dept/${id}`)
  }

  addDept(dept: any) {
    return this.http.post(`${baseApiUrl}/system/dept`, dept)
  }

  udpDept(dept: any) {
    return this.http.put(`${baseApiUrl}/system/dept`, dept)
  }

  delDept(id: number) {
    return this.http.delete(`${baseApiUrl}/system/dept/${id}`)
  }

}
